package com.atguigu.userprofile.common.dao

import com.atguigu.userprofile.common.bean.{TaskInfo, TaskTagRule}
import com.atguigu.userprofile.common.util.MysqlUtil

object TaskTagRuleDAO {

//SELECT query_value ,ti.`tag_name` FROM task_tag_rule tr JOIN tag_info ti ON tr.`sub_tag_id`=ti.`id`
  //WHERE tr.`task_id`=1
  //查询子标签与查询值的映射
  def  getTaskTagRuleListByTaskId(taskId:String): List[TaskTagRule] ={

    val sql=s"""
               |SELECT tr.id ,tr.tag_id,tr.task_id, tr.query_value ,tr.sub_tag_id,ti.`tag_name` as sub_tag_value FROM task_tag_rule tr JOIN tag_info ti ON tr.`sub_tag_id`=ti.`id`
               |   WHERE tr.`task_id`=${taskId}
               |""".stripMargin
    val taskTagRuleList: List[TaskTagRule] = MysqlUtil.queryList(sql, classOf[TaskTagRule], true)
    taskTagRuleList
  }

}
